package com.briup.demo.common.exception;

import com.briup.demo.common.response.ResultCode;
import lombok.Getter;

/**
 * 自定义异常类，用于描述和传输在业务处理中存在的问题情况以及失败的原因
 */
@Getter
public class ServiceException extends RuntimeException {

    private final int code;

    public ServiceException(String message) {
        this(500, message);
    }

    public ServiceException(int code, String message) {
        super(message);
        this.code = code;
    }

    public ServiceException(ResultCode resultCode) {
        this(resultCode.getCode(), resultCode.getMessage());
    }
}
